#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time      :2021/11/10 11:20
# @Author    :cjw
import time

from use_custom_web.base.base_page import BasePage
from use_custom_web.util.file_operator import YmlOperator
from use_custom_web.setting import ELEMENT_YML
from use_custom_web.util.log import logging


class CalendarPage(BasePage):
	"""日历主页面"""

	BasePage._locators.update(YmlOperator(ELEMENT_YML['cp']).data)
	_base_url = 'https://test-cfbs1ou0z8lv.feishu.cn/calendar/month'

	def goto_meeting_room(self):
		"""跳转到找会议室页面"""
		pass

	def goto_add_theme(self):
		"""跳转到添加主题页面"""
		pass

	def goto_add_calendar(self):
		"""跳转到添加新建日历页面"""
		from use_custom_web.page.add_calendar_page import AddCalendarPage

		self.add_icon.click()
		self.add_calendar.click()
		return AddCalendarPage(self.driver)

	def get_my_calendar(self) -> list:
		"""获取日历列表"""
		# 停顿3秒，刷新页面内容后，再获取日历列表
		time.sleep(3)
		self.driver.refresh()
		calendar_names = [item.text for item in self.calendar_itmes]
		logging.info(f'获取到的日历列表: {calendar_names}')
		return calendar_names

	def get_sub_calendar(self):
		"""获取子日历"""
		pass
